<template>
  <div class="goods-item">
    <img v-lazy="product.cover_url" alt=""/>
    <div class="goods-info">
      <p>{{ product.title }}</p>
      <span class="price"><small>$</small>{{ product.price }}</span>
      <span class="collect">{{ product.collects_count }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "GoodsListItem",
  props: {
    product: Object,
    default() {
      return {}
    }
  }
}
</script>

<style scoped lang="scss">
.goods-item {
  width: 46%;
  padding-bottom: 40px;
  /*相对位置，防止滚动时变化*/
  position: relative;

  img {
    width: 100%;
    /*圆角*/
    border-radius: 5px;
  }

  .goods-info {
    font-size: 12px;
    /*外层是相对位置，里面就是绝对位置，为毛呢？*/
    position: absolute;
    bottom: 5px;
    /*居中*/
    left: 0;
    right: 0;
    overflow: hidden;
    text-align: center;

    .p {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      margin-bottom: 3px;
    }

    .price {
      color: red;
      margin-right: 20px;
    }

    .collect {
      position: relative;
    }

    /*加入图标*/
    .collect::before {
      content: '';
      position: absolute;
      left: -15px;
      width: 14px;
      height: 14px;
      top: -1px;
      background: url('~@/assets/images/collection.png') 0 0/14px 14px;
    }
  }
}
</style>
